package com.xgz.service.impl;

import com.xgz.entity.TRoleMenu;
import com.xgz.service.TRoleMenuService;
import com.xgz.dao.TRoleMenuDao;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * (TRoleMenu)表服务实现类
 *
 * @author makejava
 * @since 2022-10-26 19:03:27
 */
@Service
public class TRoleMenuServiceImpl implements TRoleMenuService {
   @Autowired
   private TRoleMenuDao tRoleMenuDao;

   @Override
   public boolean updRoleMenu(Integer rid, String mids) {
      //删除但前信息的角色的id所拥有的菜单信息
      TRoleMenu tRoleMenu = new TRoleMenu();
      tRoleMenu.setRid(rid);
      int delete = tRoleMenuDao.delete(tRoleMenu);
      //给当前角色添加新的菜单的信息
      if (mids != null){
         String[] split = mids.split(",");
         for (String mid: split){
            int i = Integer.parseInt(mid);
            TRoleMenu tRoleMenu1 = new TRoleMenu(rid, i);
            tRoleMenuDao.insert(tRoleMenu1);
         }
      }
      return delete>0;
   }
}

